// CloneEWF.cpp : Defines the entry point for the DLL application.
//
// Copyright (c) 2004 SJJ Embedded Micro Solutions, LLC
// All Rights Reserved
// Code is provided AS IS without any warranty

#include "stdafx.h"
#include "stdio.h"

extern "C"
{
#include "ewfapi.h"
}

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
    switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
	return TRUE;
}

CLONEEWF_API bool fnCLONEEWF(void)
{
	HANDLE hDisk;
	WCHAR szDrive[20];
	BOOL bResult =FALSE;
	
	//Get infor about drive to commit changes
	swprintf(szDrive, L"\\\\.\\c:");
		
	//Next, Open the handle and check for errors
	hDisk = EwfMgrOpenProtected(szDrive);					
	
	//Commit Changes. Display error box if Commit fails
	bResult = EwfMgrCommit(hDisk);
	if (!bResult)
	{
		MessageBox(NULL,"EwfMgrCommit failed", "Error", MB_OK);
	}
   	
	MessageBox(NULL,"System Resealed!", "Reseal Complete. ", MB_ICONEXCLAMATION | MB_OK);

	//Close Handle
	EwfMgrClose(hDisk);

	return TRUE;
}

